package cn.edu.bjfu.it.oyss.covid_19helper;

import android.view.View;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

import java.util.ArrayList;

public class LoginActivity extends AppCompatActivity {
    public static final int LOGIN_ID_RESULT_CODE = 1;
    public static String LOGIN_PHONE = "";
    ArrayList<String> username;
    ArrayList<String> passwd;
    public TextView loginPhone;
    TextView loginPasswd;
    TextView verifyPhone;
    TextView verifyPasswd;
    TextView signPhone;
    TextView signPasswd1;
    TextView signPasswd2;
    Button login;
    Button verify;
    Button sign;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        TabHost th= findViewById(R.id.tabhost);
        th.setup();            //初始化TabHost容器
        //在TabHost创建标签，然后设置：标题／图标／标签页布局
        th.addTab(th.newTabSpec("tab1").setIndicator("密码登陆").setContent(R.id.tab1));
        th.addTab(th.newTabSpec("tab2").setIndicator("验证码登陆").setContent(R.id.tab2));
        th.addTab(th.newTabSpec("tab3").setIndicator("注册",null).setContent(R.id.tab3));

        username = new ArrayList<>();
        username.add("15010746989");
        passwd = new ArrayList<>();
        passwd.add("123456");

        //loginPhone.findViewById(R.id.loginPhone);
//        loginPasswd.findViewById(R.id.loginPasswd);
//        verifyPhone.findViewById(R.id.verifiPhone);
//        verifyPasswd.findViewById(R.id.verifiPasswd);
//        signPhone.findViewById(R.id.signPhone);
//        signPasswd1.findViewById(R.id.signPasswd1);
//        signPasswd2.findViewById(R.id.signPasswd2);
//        login.findViewById(R.id.login);
//        verify.findViewById(R.id.verify);
//        sign.findViewById(R.id.sign);
//        login.setOnClickListener(v -> {
//            for (int i = 0;i<username.size();i++){
//                if (loginPhone.getText().equals(username.get(i)))
//                    if(loginPasswd.getText().equals(passwd.get(i)))
//                        LOGIN_PHONE = username.get(i);
//            }
//        });
//        sign.setOnClickListener(v -> {
//            if(signPasswd1.getText().equals(signPasswd2.getText())){
//                for (String s : username) {
//                    if (s.contentEquals(signPhone.getText())) {
//                        Toast toast = Toast.makeText(this, "该手机号已经注册", Toast.LENGTH_SHORT);
//                        toast.show();
//                        return;
//                    }
//                }
//                username.add((String) signPhone.getText());
//                passwd.add((String) signPasswd1.getText());
//                AlertDialog.Builder builder = new AlertDialog.Builder(this);
//                builder.setTitle("你的手机号码为：" + signPhone.getText() + "，注册成功");
//                builder.setPositiveButton("确认", null);
//                builder.show();
//            }else{
//                Toast toast = Toast.makeText(this, "两次密码不一致", Toast.LENGTH_SHORT);
//                toast.show();
//            }
//        });
    }
}